<?php

class Sgit_Form_Element_Fecha extends Zend_Form_Element_Text
{
    
    public function init()
    {

       $this->setAttrib('class','fecha')->addFilters(array('Null','StringTrim'));
      
       $locale= Zend_Registry::get('Zend_Locale');    
       switch($locale)
       {
            case 'en_GB':
                $format='yyyy-MM-dd';
                $validator = new Zend_Validate_Regex(array('pattern' => '/^[0-9]{4}.[0-9]{2}.[0-9]{2}$/'));
                break;
            default:
                $format='dd-MM-yyyy';
                $validator = new Zend_Validate_Regex(array('pattern' => '/^[0-9]{2}.[0-9]{2}.[0-9]{4}$/'));
       }
        
        
        $validator->setMessage(
            "Date does not match the format '$format'",
            Zend_Validate_Regex::NOT_MATCH
        );
         
            

       $this->addValidator($validator,true);
       
  
    }
}
